

USE [WebSecurity]
GO

GO
-- Drop stored procedure if it already exists
IF EXISTS (
  SELECT * 
    FROM INFORMATION_SCHEMA.ROUTINES 
   WHERE SPECIFIC_CATALOG = N'WebSecurity' 
	 AND SPECIFIC_SCHEMA = N'dbo'
     AND SPECIFIC_NAME = N'UsersInRoles_ins' 
)
   DROP PROCEDURE dbo.UsersInRoles_ins
GO
create procedure UsersInRoles_ins

	@UsersInRoleID Int = null OUTPUT,
	@CreatedBy VarChar(50),
	@CreatedDt DateTime,
	@ModifiedBy VarChar(50),
	@ModifiedDt DateTime,
	@UserId Int,
	@ApplicationRoleId Int,
        @RowsAffected int = null OUTPUT 
	
--*************************************************************
--Created By: trooks
--Name: dbo_UsersInRoles_ins
--Schema: dbo
--Table: UsersInRoles
--Database: WebSecurity
--Created Date: 01/21/2013 00:00:00
--*************************************************************

as
	Begin Try
        insert into [dbo].UsersInRoles
		(
		CreatedBy, 
		CreatedDt, 
		ModifiedBy, 
		ModifiedDt, 
		UserId, 
		ApplicationRoleId 
    )
    values
    (
		@CreatedBy, 
		@CreatedDt, 
		@ModifiedBy, 
		@ModifiedDt, 
		@UserId, 
		@ApplicationRoleId 
        )
		Set @UsersInRoleID = SCOPE_IDENTITY(); 
		Set @RowsAffected = @@ROWCOUNT;
		return 0;	
	END TRY
	BEGIN CATCH
		Set @RowsAffected = 0;
		EXEC dbo.uspLogError;
		return -1;
	END CATCH
	
GO
GRANT EXECUTE ON [WebSecurity].[dbo].[UsersInRoles_ins] to PORTAL_WebSecurity
GO




